package com.peter.radio_group_button;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.widget.RadioGroup;

public class RadioActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_radio);

        init();
    }

    private void init() {
        RadioGroup radioGroup = findViewById(R.id.rgSwitch);
        radioGroup.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
            @Override
            public void onCheckedChanged(RadioGroup radioGroup, int i) {
                switch (i) {
                    case R.id.rbEnable:
                        Log.e(TAG,"Enabled");
                        break;
                    case R.id.rbUnEnable:
                        Log.e(TAG,"Unable");
                        break;
                }
            }
        });
    }

    private static final String TAG = "RadioGroup和RadioButton 的简单使用举例";
}